function [Fu Cf A R]=corr3(I)
 [rows,cols]=size(I);
 [x,y] = meshgrid(1:rows,1:cols);
  
 M=64;
 N=360;
 
 I1 = I.*((-1).^(x+y));            
 Tf=(fft2(I1));
 magF=(sqrt(real(Tf).^2 + imag(Tf).^2));
 Temp1=LPM(magF);
  
 [rows,cols]=size(Temp1);
 [x,y] = meshgrid(1:cols,1:rows);
  
 I2 = Temp1.*((-1).^(x+y));            
 Fp =(fft2(I2));
 phaseF = atan2(imag(Fp),real(Fp));             % Fase de la imagen
 e=exp(1j*phaseF);
 
 RT=[];
 mayor=0;
 
 for key=1:100
   RandStream.setDefaultStream(RandStream('mt19937ar','seed',key));
   W=-1 + (1-(-1)).*rand(M/2,N/2);
   W2=upsampled(W);  
  
   
   W2(W2<=0)=-1;
   W2(W2>0)=1;
   
   %g(33:96,1:360)=W2;
   
   I2 = W2.*((-1).^(x+y));  
   Rg=fft2(double(I2));
   
   
   G=conj(Rg);
   
   r=ifft2(e.*G);
   RT(key)=max(max(real(r)));
   
   if(RT(key)>mayor)  %no es necesario regresar la r mayor.
     mayor=RT(key);
     ret=r;
   end
 end

 Fu=real(Temp1);
 Cf=real(ret);
 [a b]=max(RT);
 R=num2str(b);
 A=RT;
end